Repository navigation
Add detector-to-decision layer for region-based VLM inference - #37
Open
r33drichards wants to merge 9 commits into
Open
r33drichards wants to merge 9 commits into
r33drichards wants to merge 9 commits into
Conversation
Work-in-progress sketch, not final: the design is still being brainstormed. Adds duck-typed adapters from detector outputs (OmniParser, ultralytics, supervision/RF-DETR, SAM masks, transformers pipelines) to Region objects, select() (Set-of-Mark choice over boxes with a knockout for many boxes), map_regions() (the same questions per crop) and stream() (background detection with optional stale-frame dropping), plus a draft how-to page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H
benchmarks/marks_probe.py asks whether a checkpoint can read Set-of-Mark numbers on synthetic coloured squares (digit reading, 2/4/8 marked boxes, large tags, and a position-words control without marks). Exploratory, not a published number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H
--contextual scores each question on a blank image (cached per question) and divides that prior out, to test whether the checkpoint's label bias toward "box 2" can be removed without training. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H
Snapshots of two exploratory probe scripts still being run; results not yet reviewed. Not published numbers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H
benchmarks/zoom_search_probe.py replaces C1's oracle box with the model's own search on V*Bench direct_attributes. Every variant answers on the same zoom level (a 4x4 grid cell, grown 25%) and differs only in how the cell is chosen: oracle cell (ceiling), two quadrant choice questions, a hierarchical yes/no search over quadrants (8 crops), or yes/no on all 16 cells. Exploratory, not a published number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H
hier3 runs the yes/no search three levels deep (12 crops) and centres a square crop on the score-weighted centroid of the last level's cells; oracle_centred puts the same-size crop on the true target centre, the ceiling for that crop size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H
site-docs/reference/results/detector-regions-and-zoom.md writes up the marks, crop, zoom-ceiling and zoom-search probes (exploratory CPU runs on the released checkpoint, no headline numbers). The how-to for the draft regions layer now warns that numbered marks are mostly not read and points to the zoom-search results. zoom_search_probe.py: in-progress beam2 variant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H
beam2 keeps the top 2 quadrants at the first level: the final crop holds the target more often (52% -> 63.5%, 19 gained / 6 lost) but accuracy moves within noise (48.7% -> 51.3%, p = 0.65) for 60% more crops. Exploratory, not a published number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new
laya.regionsmodule that bridges object detectors and the VLM decision model, enabling two key workflows: selecting one region from a detector's output, and mapping decisions across multiple regions via cropping.Key Changes
New
laya/regions.pymodule (511 lines):Regiondataclass representing detections with pixel boxes, optional labels, scores, and masksas_regions,from_ultralytics,from_supervision,from_sam,from_omniparser,from_hf_pipeline) supporting YOLO, RT-DETR, RF-DETR, SAM, OmniParser, and transformers pipelinesselect()function for one-choice questions over regions with Set-of-Mark visualization and knockout rounds for large region countsmap_regions()function for applying questions to each region's cropstream()function for processing frame sequences with background detectionRegionPipelineclass wrapping the above for convenient chainingdraw_marks()for numbered region visualizationComprehensive test suite (
tests/test_regions.py, 220 lines):Benchmark probes for measuring effectiveness:
benchmarks/marks_probe.py: Synthetic Set-of-Mark readability test (digit and colored box recognition)benchmarks/crop_probe.py: COCO ground-truth crop verification and 8-way classificationbenchmarks/zoom_probe.py: Oracle zoom ceiling on V*Bench small objectsbenchmarks/zoom_search_probe.py: Glance-then-zoom search strategiesDocumentation (
site-docs/how-to/detector-regions.md):select()andmap_regions()workflowsModule exports: Added
RegionandRegionPipelinetolaya/__init__.pyNotable Implementation Details
REGIONS_FORMAT_VERSIONtracks changes to mark drawing and option formattingstream()runs detection on a background thread while the decision model processes the current frame, with optional frame dropping for real-time constraintshttps://claude.ai/code/session_01XCUwTdDJhkMRhS21sZ8x8H